package br.com.affero.facade;

import br.com.affero.bean.Document;
import br.com.affero.bean.User;
import br.com.affero.dao.DocumentDAO;
import br.com.affero.dao.UserDAO;

public class DomainFacade {

	private static DomainFacade instance;
	private UserDAO userDAO;
	private DocumentDAO documentDAO;
	
	private DomainFacade() {
		userDAO = new UserDAO();
		documentDAO = new DocumentDAO();
	}
	
	public static DomainFacade getInstance() {
		if (instance == null) {
			instance = new DomainFacade();
		}
		return instance;
	}
	
	public User getUser(int id) {
		return userDAO.get(id);
	}
	
	public void insertDocument(Document document, User user) {
		documentDAO.save(document, user);
	}
	
	public void updateDocument(Document document) {
		documentDAO.save(document, null);
	}
	
	public Document getDocument(int id) {
		return documentDAO.get(id);
	}
	
	public void deleteDocument(Document document) {		
		documentDAO.delete(document);
	}
	
}
